how to set-header on istio1.10

  1. prepare chenshi.yaml

    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: chenshi
      namespace: chenshi
    spec:
      hosts:
      - "chenshi.net"
      gateways:
      - istio-system/chenshi
      http:
      - match:
        - uri:
            prefix: "/test"
        rewrite:
          uri: "/"
        route:
        - destination:
            host: chenshi
            port:
              number: 80
          headers:
            response:
              set:
                Cache-Control: "no-cache"
    
  2. extra(haproxy)

    http-response set-header Cache-Control "no-cache"
    http-response set-header Access-Control-Allow-Origin "*"
    http-response set-header Access-Control-Allow-Credentials true
    http-response set-header Access-Control-Allow-Headers "token"
    http-response set-header Access-Control-Allow-Methods "GET, POST"
    acl allow_host src 192.168.1.1/32
    http-request allow if allow_host
    http-request deny